var vm = new Vue({
    //vue对象节点,指向父盒子
    el:'#suc',                                                            
    //vue实例 的data属性
    data:function(){
        return{
        	pageA:true,
        	tableData:[],
        	newFlag:false,
        	//分页条
  	        pageSize:10,
  	        currPage:1,
  	        total:1,
  	        lostEditorEdit:null,
  	        //
  	        lostTopic:{},
  	        //帖子详情
  	        topic:{},
  	        topicV:false,
  	        topicData:{
  	    	  "user":{},
  	    	  "plate":{}
  	        }
  	        
        }
    },
    //vue实例 的methods
    methods:{
    	handleSizeChange:function(val) {
            vm.pageSize = val;
            vm.loadData();
         },
         handleCurrentChange:function(val) {
      	   vm.currPage = val;
      	   vm.loadData();
         },
         //格式化日期
         dateFormat:function(row,column){
      	   var date = row[column.property];
      	   if(date == undefined){
      		   return "";
      	   }
      	   return moment(date).format("YYYY-MM-DD HH:mm:ss");
         },
         statusFormat:function(row,column){
      	   var i = row[column.property];
      	   if(i == undefined){
      		   return "";
      	   }else if(i =='0' ){
      		  i="进行中"; 
      	   }
      	   else if(i =='1' ){
       		  i="完结"; 
       	   }
      	   else if(i =='2' ){
       		  i="禁言"; 
       	   }else if(i =='3' ){
       		  i="删除"; 
       	   }
      	   return i;
         },
         loadData:function(){

      	   var url = "./listTopic.action";
  
      	   var params = {
      			"pagemap.page":vm.currPage,
                "pagemap.size":vm.pageSize
      	   }
      	   pb.ajaxPost(url,params,function(r){
  	       		if(r.code == '000000'){
  	       			vm.tableData = r.topicList;
  	       			var nowDate = new Date().getTime();
  	       			var arr = [];
  	       			if(vm.tableData !== null && vm.tableData.length>0){
  	       				for(var i=0;i<vm.tableData.length;i++){
  	       					if(vm.tableData[i].tstatus == '1'){
	  	       					var tempDate = new Date(vm.tableData[i].t_create_time).getTime();
	  	       					vm.tableData[i].flag = nowDate - tempDate > (1 * 3600 * 1000 * 24)?0:1;
	  	       					
	  	       					vm.lostEditorEdit.setContent(vm.tableData[i].tcontent);
	  	       					vm.tableData[i].tcontent = vm.lostEditorEdit.getContentTxt();
	  	       					arr.push(vm.tableData[i]);
  	       					}
  	       					
  	       					
  		       			}
  	       			}
  	       		    vm.tableData = [];
  	       		    vm.tableData = arr;
  	       			vm.total = r.topiccount;
  	       		}else{
                 		pb.alertErr("加载失败");
                 	}
  	       },function(err){
  	    	   pb.alertErr("加载失败");
  	       });
         },
         getRecord(tid){
      	   var url = "./getTopicById.action";
      	   var params = {
      		   'topic.tid':tid
      	   }
      	   pb.ajaxPost(url,params,function(r){
  	       		if(r.code == '000000'){
  	       			vm.topicData = r.topic;
  	       			vm.lostEditorEdit.setContent(vm.topicData.tcontent);
  	       			vm.topicData.createDate = moment(vm.topicData.t_create_time).format('YYYY-MM-DD');
  	       			vm.topicData.tcontent = vm.lostEditorEdit.getContent();
  	       			$('#content').append(vm.topicData.tcontent);
  	       			//vm.lostEditorEdit.setContent('');
  	       		}else{
  	       		 pb.alertErr('获取信息失败');
  	       		}
  	       },function(err){
  	    	   pb.alertErr('获取信息失败');
  	       });
         },
         open(tid){
      	   /*$('#content').empty();
      	   vm.topicV = true;
      	   vm.getRecord(tid);*/
           window.parent.vm.goTo('viewTopic',tid);
         },
         getEdit:function(){
        	 vm.lostEditorEdit = UM.getEditor("lostEditorEdit");
         }
         

    }
    //vue实例 的methods结束
});
vm.loadData();
vm.getEdit();